/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.project.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Malek
 */
@Entity
@Table(name = "COMMANDE", catalog = "", schema = "ONECOMMERCE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Commande.findAll", query = "SELECT c FROM Commande c"),
    @NamedQuery(name = "Commande.findByIdcom", query = "SELECT c FROM Commande c WHERE c.idcom = :idcom"),
    @NamedQuery(name = "Commande.findByDatecom", query = "SELECT c FROM Commande c WHERE c.datecom = :datecom")})
public class Commande implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDCOM", nullable = false, precision = 22, scale = 0)
    private BigDecimal idcom;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DATECOM", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date datecom;
    @JoinColumn(name = "IDITEM", referencedColumnName = "IDITEM", nullable = false)
    @ManyToOne(optional = false)
    private Item iditem;
    @JoinColumn(name = "IDFOUR", referencedColumnName = "IDFOUR", nullable = false)
    @ManyToOne(optional = false)
    private Fournisseur idfour;

    public Commande() {
    }

    public Commande(BigDecimal idcom) {
        this.idcom = idcom;
    }

    public Commande(BigDecimal idcom, Date datecom) {
        this.idcom = idcom;
        this.datecom = datecom;
    }

    public BigDecimal getIdcom() {
        return idcom;
    }

    public void setIdcom(BigDecimal idcom) {
        this.idcom = idcom;
    }

    public Date getDatecom() {
        return datecom;
    }

    public void setDatecom(Date datecom) {
        this.datecom = datecom;
    }

    public Item getIditem() {
        return iditem;
    }

    public void setIditem(Item iditem) {
        this.iditem = iditem;
    }

    public Fournisseur getIdfour() {
        return idfour;
    }

    public void setIdfour(Fournisseur idfour) {
        this.idfour = idfour;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcom != null ? idcom.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commande)) {
            return false;
        }
        Commande other = (Commande) object;
        if ((this.idcom == null && other.idcom != null) || (this.idcom != null && !this.idcom.equals(other.idcom))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.project.entities.Commande[ idcom=" + idcom + " ]";
    }
    
}
